// pages/user-address/index.js
import api from "../../api/index.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    addressList: [],
    modelType:1//默认地址类型删除模式
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options && options.modalType) {
      this.setData({
        modalType:options.modalType
      })
    }
    this.initData()
  },
  initData(){
    api.addressList({data:{}})
    .then((res)=>{
      this.setData({
        addressList:res.data
      })
    })
  },
  onSelectedOk(parma){
    // wx.setStorageSync("currentAddress",parma.detail.currentAddress)
    debugger
    getApp().eventBus.emit("defaultAddressUpdate",parma.detail.currentAddress)
    getApp().globalData.defaultAddress=parma.detail.currentAddress
    wx.navigateBack({
      delta: 1
    })
  }
})